﻿@inherits LayoutComponentBase
@inject NavigationManager NavigationManager

<PageTitle>图灵进销存管理</PageTitle>

<div class="page">
    <div class="sidebar">
        <CascadingValue Value="this">
           <NavMenu />
        </CascadingValue>
    </div>

    <main>
        <div class="top-row px-4">
            <RadzenDropDown @bind-Value=@value Data=@companyNames Change=@OnChanged/>
        </div>

        <article class="content px-4">
            @Body
        </article>
    </main>
</div>
<RadzenComponents />
@code {
    public string value = "修改密码";
    public List<string> companyNames;
    
    public void InsertLoginUser()
    {
        companyNames.Insert(0, AppSession.User.Name);
        value = AppSession.User.Name;
        StateHasChanged();
    }

    private void OnChanged(object args)
    {
        if (value == "修改密码")
        {
            NavigationManager.NavigateTo("/changepassword");
        }
        else if (value == "退出登录")
        {
            NavigationManager.NavigateTo("/login");
        }
    }

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        companyNames = new List<string>
        {
            "修改密码",
            "退出登录"
        };
    }
}
